<?php
require_once 'constants.php';
require_once 'db.php';

$imgIds = "";
$order_by = $_GET['order_by'];
$max_rows = $_GET['max_rows'];

//Determine which column to order by
$order_by_clause = "";
if ( $order_by == "publish_date" ) {
    $order_by_clause = "order by publish_date desc";
}

$max_rows_clause = "";
if ( isset($max_rows) ) {
    $max_rows_clause = "limit $max_rows";
}

$rows = dbGetApprovedImageInfos($order_by_clause, $max_rows_clause);

for ( $i = 0; $i < count($rows); $i++ ) {
    $row = $rows[$i];
    $imgIds .= $row['id'];
    if ( $i < count($rows) - 1 ) {
        $imgIds .= "|";
    }
}

print $imgIds;

?>
